package com.tjetc.service;

import com.tjetc.dao.BossDao;
import com.tjetc.domain.Boss;
import com.tjetc.domain.Person;

import java.sql.SQLException;

public class BossService {
    private BossDao bossDao=new BossDao();

    public Boss findBossByBossId(int bossId) {
        try {
            return bossDao.findBossByBossId(bossId);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }

    public Person log(String username, String password) {
        try {
            return bossDao.log(username, password);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }

    public boolean updateUsername(String newUsername, int bossId) {
        try {
            return bossDao.updateUsername(newUsername,bossId);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return false;
    }

    public boolean updatePassword(String newPassword, int bossId) {
        try {
            return bossDao.updatePassword(newPassword,bossId);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return false;
    }

    public boolean updateName(String newName, int bossId) {
        try {
            return bossDao.updateName(newName,bossId);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return false;
    }

    public boolean updatePhone(String newPhone, int bossId) {
        try {
            return bossDao.updatePhone(newPhone,bossId);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return false;
    }

    public Boss findBossByusername(String username) {
        try {
            return bossDao.findBossByusername(username);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
}
